using Gateway.IApplication.Order;
using Gateway.IQuery.Order;
using Microsoft.AspNetCore.Authorization;

namespace Gateway.UI.Api.Controllers;

/// <summary>
/// 
/// </summary>
[AllowAnonymous]
public class OrderController : BaseController
{
   private readonly IOrderApp _orderApp;
   private readonly IOrderQuery _orderQuery;
   /// <summary>
   /// 
   /// </summary>
   /// <param name="orderApp"></param>
   /// <param name="orderQuery"></param>
   public OrderController(IOrderApp orderApp, IOrderQuery orderQuery)
   {
      _orderApp = orderApp;
      _orderQuery = orderQuery;
   }

   /// <summary>
   /// 
   /// </summary>
   /// <param name="orderTime"></param>
   /// <returns></returns>
   [HttpPost,Route("add")]
   public async Task<string> Add(DateTime orderTime)
   {
      return await _orderApp.Add(orderTime);
   }


   /// <summary>
   /// 
   /// </summary>
   /// <param name="id"></param>
   /// <returns></returns>
   [HttpGet("detail")]
   public async Task<object> GetDetail(string id)
   {
      return await _orderQuery.GetDetail(id);
   }
   
   
   /// <summary>
   /// 
   /// </summary>
   /// <param name="area"></param>
   /// <param name="page"></param>
   /// <param name="size"></param>
   /// <returns></returns>
   [HttpGet("list")]
   public async Task<object> GetList([FromQuery]string area, [FromQuery] int page, [FromQuery] int size)
   {
      return await _orderApp.GetList(area,page,size);
   }
}